package com.fire.control.system.module.device.dao;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.fire.control.system.entity.DeviceGroup;
/**
 * 
 * @ClassName:  DeviceGroupRepository
 * @Description:  设备组持久层
 * @author:  xiechengguang
 * @date:  2017年5月11日 下午3:20:02
 *
 */
@Repository
public interface DeviceGroupRepository extends JpaRepository<DeviceGroup, String> {

	@Query("from DeviceGroup d where d.groupName like %:groupName%")
	public List<DeviceGroup> searchDeviceGroups(@Param("groupName")String groupName);
	
	@Query("from DeviceGroup")
	public List<DeviceGroup> getDeviceGroups();
	
	@Transactional
	@Modifying
	@Query("update DeviceGroup d set d.status = false where d.id = :id")
	public int updateDeviceGroupStatus(@Param("id") String id);
	
	
	
	
}
